# SETTINGS SECTION

PYWORDNET_PATH = '../../misc'
DICT_PATH = '../../misc/mzdict'
ENCODING = 'utf-8'
DELIMITER = '\t'

# END OF SETTINGS

import os,sys
if PYWORDNET_PATH not in sys.path:
	sys.path.append(PYWORDNET_PATH)
os.environ['WNSEARCHDIR'] = os.path.join(PYWORDNET_PATH, 'pywordnet/dict')
import pywordnet as wordnet

import os
import codecs

# Load dictionary at startup
mainDict = {}
for fileName in os.listdir(DICT_PATH):
	if fileName.endswith('.txt'):
		filePath = os.path.join(DICT_PATH, fileName)
		lineNum = 0
		print 'LOOKUP: reading', filePath
		for line in codecs.open(filePath, encoding=ENCODING).readlines():
			columns = line.strip().split(DELIMITER)
			lineNum += 1
			if len(columns) >= 3:
				word = columns[0].strip()
				category = columns[1].strip()
				description = columns[2].strip()
				if mainDict.has_key(word):
					mainDict[word] += '(%s) %s\n' % (category, description)
				else:
					mainDict[word] = '(%s) %s\n' % (category, description)
			else:
				print 'WARNING: invalid entry at line', lineNum
mainDictSize = len(mainDict.keys())
